<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>websocket测试</title>

    <script>
            const websocket = new WebSocket('ws://127.0.0.1:8800');
            websocket.onopen = function (evt) {
                console.log('open')
            };
            websocket.onclose = function (evt) {
                console.log('close')
            };
            websocket.onmessage = function (evt) {
                console.log('接收到消息：', evt)
            };
            websocket.onerror = function (evt) {
                console.log('error')
            };

            websocket.send('hello')

            console.log(websocket)
    </script>
  </head>

  <body></body>
</html>
